import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/api/google_play/api_google_play_transaction_revocation_reason.dart';

const kApiGooglePlayPurchasedItemOtherRevocationReasonValue = 'other';
const kApiGooglePlayPurchasedItemRemorseRevocationReasonValue = 'remorse';
const kApiGooglePlayPurchasedItemNotReceivedPurchaseRevocationReasonValue = 'not_received_purchase';
const kApiGooglePlayPurchasedItemDefectivePurchaseRevocationReasonValue = 'defective_purchase';
const kApiGooglePlayPurchasedItemAccidentalPurchaseRevocationReasonValue = 'accidental_purchase';
const kApiGooglePlayPurchasedItemFraudRevocationReasonValue = 'fraud';
const kApiGooglePlayPurchasedItemFriendlyFraudRevocationReasonValue = 'friendly_fraud';
const kApiGooglePlayPurchasedItemChargebackRevocationReasonValue = 'chargeback';

class ApiGooglePlayTransactionRevocationReasonDto extends Equatable {
  const ApiGooglePlayTransactionRevocationReasonDto._internal({
    required this.reasonString,
  });

  final String reasonString;

  @override
  List<Object?> get props {
    return [
      reasonString,
    ];
  }

  factory ApiGooglePlayTransactionRevocationReasonDto.fromEntity(
      ApiGooglePlayTransactionRevocationReason reason) {
    late final String reasonString;

    if (reason == ApiGooglePlayTransactionRevocationReason.other) {
      reasonString = kApiGooglePlayPurchasedItemOtherRevocationReasonValue;
    } else if (reason == ApiGooglePlayTransactionRevocationReason.remorse) {
      reasonString = kApiGooglePlayPurchasedItemRemorseRevocationReasonValue;
    } else if (reason == ApiGooglePlayTransactionRevocationReason.notReceivedPurchase) {
      reasonString = kApiGooglePlayPurchasedItemNotReceivedPurchaseRevocationReasonValue;
    } else if (reason == ApiGooglePlayTransactionRevocationReason.defectivePurchase) {
      reasonString = kApiGooglePlayPurchasedItemDefectivePurchaseRevocationReasonValue;
    } else if (reason == ApiGooglePlayTransactionRevocationReason.accidentalPurchase) {
      reasonString = kApiGooglePlayPurchasedItemAccidentalPurchaseRevocationReasonValue;
    } else if (reason == ApiGooglePlayTransactionRevocationReason.fraud) {
      reasonString = kApiGooglePlayPurchasedItemFraudRevocationReasonValue;
    } else if (reason == ApiGooglePlayTransactionRevocationReason.friendlyFraud) {
      reasonString = kApiGooglePlayPurchasedItemFriendlyFraudRevocationReasonValue;
    } else if (reason == ApiGooglePlayTransactionRevocationReason.chargeback) {
      reasonString = kApiGooglePlayPurchasedItemChargebackRevocationReasonValue;
    }

    return ApiGooglePlayTransactionRevocationReasonDto._internal(
      reasonString: reasonString,
    );
  }

  @override
  String toString() {
    return reasonString;
  }
}
